package algorithm.easy;

import java.util.Scanner;

/**
 * @author 江岸
 * @version V1.0
 * @ClassName: RepeatedSubstringPattern459
 * @description: 给定一个非空的字符串，判断它是否可以由它的一个子串重复多次构成。给定的字符串只含有小写英文字母，并且长度不超过10000
 * @date 2020/8/2410:04
 * @since V1.0
 */
public class RepeatedSubstringPattern459 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String next = in.next();
        System.out.println(repeatedSubstringPattern(next));
    }


    public static boolean repeatedSubstringPattern(String s) {
        for (int n=1;n*2<=s.length();n++){
            if(s.length()%n==0){
                //字串长度为n，给定字符串长度为n的整数倍
                boolean flag = true;
                for(int j=n;j<s.length();j++){
                    if (s.charAt(j)!=s.charAt(j-n)){
                        flag = false;
                        break;
                    }
                }
                if (flag){
                    return true;
                }
            }
        }
        return false;
    }
}
